package test.proxy.sample;

/*
  Note that it is safe to make this implementation cloneable,
  because these interval are immutable, thus can share dates.
 */
//start extract TimeIntervalImpl2
import java.util.Date;

public class TimeIntervalImpl2 implements TimeInterval {
    
    private final Date start;
    private final Date end;
    
    public TimeIntervalImpl2( Date s, Date e ) {
	start = new Date(s.getTime());
	end = new Date(e.getTime());
	assert invariant() : "start>end";
    }
    
    public Date getStart() { return (Date)start.clone(); }
    
    public Date getEnd() { return (Date)end.clone(); }
    
    public boolean invariant() { return start.compareTo(end) <= 0; }
}
//stop extract TimeIntervalImpl2
